const ffmpeg = require('fluent-ffmpeg')
const ffmpegPath = require('@ffmpeg-installer/ffmpeg')
const ffprobePath = require('@ffprobe-installer/ffprobe')
const path = require('path')
const fs = require('fs')

// 定义视频文件路径
ffmpeg.setFfmpegPath(ffmpegPath.path)
ffmpeg.setFfprobePath(ffprobePath.path)

// 添加水印
ffmpeg(path.join(__dirname, './video/12.mp4'))
  .outputOptions([
    '-vf', 'drawtext=text="Hello":fontsize=30:fontcolor=red:x=10:y=10'
  ])
  .output(path.join(__dirname, 'aa.mp4')) // 输出文件
  .on('progress', (progress) => { // 监听切片进度
    console.log('Processing: ' + progress.percent + '% done')
  }).on('end', () => { // 监听结束
    console.log("视频切片完成")
  })
  .run(); // 执行